package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaEsmRequirements;
import com.ruoyi.system.service.IFaEsmRequirementsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 需求记录Controller
 * 
 * @author ruoyi
 * @date 2021-09-13
 */
@RestController
@RequestMapping("/system/requirements")
public class FaEsmRequirementsController extends BaseController
{
    @Autowired
    private IFaEsmRequirementsService faEsmRequirementsService;

    /**
     * 查询需求记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaEsmRequirements faEsmRequirements)
    {
        startPage();
        List<FaEsmRequirements> list = faEsmRequirementsService.selectFaEsmRequirementsList(faEsmRequirements);
        return getDataTable(list);
    }

    /**
     * 导出需求记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:export')")
    @Log(title = "需求记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FaEsmRequirements faEsmRequirements)
    {
        List<FaEsmRequirements> list = faEsmRequirementsService.selectFaEsmRequirementsList(faEsmRequirements);
        ExcelUtil<FaEsmRequirements> util = new ExcelUtil<FaEsmRequirements>(FaEsmRequirements.class);
        return util.exportExcel(list, "需求记录数据");
    }

    /**
     * 获取需求记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(faEsmRequirementsService.selectFaEsmRequirementsById(id));
    }

    /**
     * 新增需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:add')")
    @Log(title = "需求记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaEsmRequirements faEsmRequirements)
    {
        return toAjax(faEsmRequirementsService.insertFaEsmRequirements(faEsmRequirements));
    }

    /**
     * 修改需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:edit')")
    @Log(title = "需求记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaEsmRequirements faEsmRequirements)
    {
        return toAjax(faEsmRequirementsService.updateFaEsmRequirements(faEsmRequirements));
    }

    /**
     * 删除需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:requirements:remove')")
    @Log(title = "需求记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(faEsmRequirementsService.deleteFaEsmRequirementsByIds(ids));
    }
}
